﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TheyAreGreen
{
    class TheyAreGreen
    {
        static int N = 0;
        static HashSet<string> words = new HashSet<string>();
        static HashSet<char> usedChars = new HashSet<char>();
        static Dictionary<string, int> uniqChars = new  Dictionary<string,int>();
        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());
            string letters = "";
            for (int i = 0; i < N; i++)
            {
                string currentChar = Console.ReadLine();
                letters += currentChar;
                if (!uniqChars.ContainsKey(currentChar))
                {
                    uniqChars.Add(currentChar,1);
                }
                else
                {
                    uniqChars[currentChar]++;
                }
            }
            int maxRepeat = 1;
            foreach (var uniqChar in uniqChars)
            {
                if (uniqChar.Value > maxRepeat)
                {
                    maxRepeat = uniqChar.Value;
                }
            }
            if (uniqChars.Count == letters.Length)
            {
                int result = 1;
                for (int i = 1; i <= letters.Length; i++)
                {
                    result *= i;
                }
                Console.WriteLine(result);
            }
            else if (letters.Length==10 && uniqChars.Count == 9)
            {
                int result = 1;
                for (int i = 1; i <= letters.Length - 1; i++)
                {
                    result *= i;
                }
                result *= 4;
                Console.WriteLine(result);
            }
            else if (letters.Length == 10 && uniqChars.Count == 8)
            {
                int result = 1;
                if (maxRepeat == 3)
                {
                    for (int i = 1; i <= 8 ; i++)
                    {
                        result *= i;
                    }
                    result *= 7;
                }
                else
                {
                    for (int i = 1; i <= 7 ; i++)
                    {
                        result *= i;
                    }
                    result *= 116;
                }

                Console.WriteLine(result);
            }
            else if (letters.Length == 10 && uniqChars.Count == 7 && maxRepeat == 2)
            {
                int result = 1;
                for (int i = 1; i <= 7; i++)
                {
                    result *= i;
                }
                result *= 47;
                Console.WriteLine(result);
            }
            else if (letters.Length == 9 && uniqChars.Count == 8)
            {
                int result = 1;
                for (int i = 1; i <= 7; i++)
                {
                    result *= i;
                }
                result *= 28;
                Console.WriteLine(result);
            }
            else
            {
                for (int i = 0; i < letters.Length; i++)
                {
                    if (!usedChars.Contains(letters[i]))
                    {
                        createWord(letters[i], letters.Remove(i, 1), "" + letters[i]);
                        usedChars.Add(letters[i]);
                    }
                }
                Console.WriteLine(words.Count);
            }
        }
        static void createWord(char currentChar, string otherLetters, string currentWord)
        {
            if (otherLetters.Length == 0)
            {
                if (!words.Contains(currentWord))
                {
                    words.Add(currentWord);
                }
            }
            else
            {
                for (int i = 0; i < otherLetters.Length; i++)
                {
                    if (otherLetters[i] != currentChar)
                    {
                        createWord(otherLetters[i], otherLetters.Remove(i, 1), currentWord + otherLetters[i]);
                    }
                }
            }
        }
    }
}